<template>
  <div>
    <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <input 
      v-model="name"
      @keydown.enter="Add(name)" 
      class="new-todo" 
      placeholder="请输入任务名称" 
      autofocus />
    </header>
  </div>
</template>

<script>
export default {
  name: 'VueDemoTodoHeader',

  data() {
    return {
        name: ''
    };
  },

  mounted() {
    
  },

  methods: {
    Add(name) {
      if (name === '') return alert('请输入数据')
      this.$emit('isAdd', name)
      this.name = ''
    }
  },
};
</script>

<style lang="scss" scoped>

</style>